﻿using System;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Text;
using System.Windows.Forms;

namespace HslCommunication.Controls
{
	/// <summary>
	/// 一个时钟控件
	/// </summary>
	// Token: 0x02000170 RID: 368
	public class UserClock : UserControl
	{
		/// <summary>
		/// 实例化一个时钟控件
		/// </summary>
		// Token: 0x06001E4C RID: 7756 RVA: 0x00091750 File Offset: 0x0008F950
		public UserClock()
		{
			this.InitializeComponent();
			this._Time1s.Interval = 50;
			this._Time1s.Tick += this._Time1s_Tick;
			this.DoubleBuffered = true;
		}

		// Token: 0x06001E4D RID: 7757 RVA: 0x000917EE File Offset: 0x0008F9EE
		private void ClockMy_Load(object sender, EventArgs e)
		{
			this.BackgroundImage = this._BackGround();
			this._Time1s.Start();
		}

		// Token: 0x06001E4E RID: 7758 RVA: 0x0009180A File Offset: 0x0008FA0A
		private void _Time1s_Tick(object sender, EventArgs e)
		{
			this._NowTime = DateTime.Now;
			base.Invalidate();
		}

		// Token: 0x06001E4F RID: 7759 RVA: 0x00091820 File Offset: 0x0008FA20
		private Bitmap _BackGround()
		{
			int width = base.Width;
			Bitmap bitmap = new Bitmap(width - 20, width - 20);
			Graphics graphics = Graphics.FromImage(bitmap);
			graphics.SmoothingMode = SmoothingMode.AntiAlias;
			Point point = new Point(bitmap.Width / 2, bitmap.Height / 2);
			int num = (bitmap.Width - 1) / 2;
			Rectangle rect = new Rectangle(0, 0, bitmap.Width - 1, bitmap.Width - 1);
			Rectangle rect2 = new Rectangle(2, 2, bitmap.Width - 5, bitmap.Width - 5);
			Rectangle rect3 = new Rectangle(point.X - 4, point.Y - 4, 8, 8);
			Rectangle rectangle = new Rectangle(5, 5, bitmap.Width - 11, bitmap.Width - 11);
			Rectangle rectangle2 = new Rectangle(8, 8, bitmap.Width - 17, bitmap.Width - 17);
			graphics.FillEllipse(Brushes.DarkGray, rect);
			graphics.FillEllipse(Brushes.White, rect2);
			graphics.DrawEllipse(new Pen(Brushes.Black, 1.5f), rect3);
			graphics.TranslateTransform((float)point.X, (float)point.Y);
			for (int i = 0; i < 60; i++)
			{
				graphics.RotateTransform(6f);
				graphics.DrawLine(Pens.DarkGray, new Point(num - 3, 0), new Point(num - 1, 0));
			}
			for (int j = 0; j < 12; j++)
			{
				graphics.RotateTransform(30f);
				graphics.DrawLine(new Pen(Color.Chocolate, 2f), new Point(num - 6, 0), new Point(num - 1, 0));
			}
			graphics.ResetTransform();
			Font font = new Font("Microsoft YaHei UI", 12f);
			int num2 = num / 2;
			int num3 = (int)((double)num * Math.Sqrt(3.0) / 2.0);
			graphics.DrawString("1", font, Brushes.Green, new PointF((float)(num + num2 - 13), (float)(num - num3 + 4)));
			graphics.DrawString("2", font, Brushes.Green, new PointF((float)(num + num3 - 17), (float)(num - num2 - 2)));
			graphics.DrawString("3", font, Brushes.Green, new PointF((float)(2 * num - 18), (float)(num - 8)));
			graphics.DrawString("4", font, Brushes.Green, new PointF((float)(num + num3 - 18), (float)(num + num2 - 14)));
			graphics.DrawString("5", font, Brushes.Green, new PointF((float)(num + num2 - 14), (float)(num + num3 - 19)));
			graphics.DrawString("6", font, Brushes.Green, new PointF((float)(num - 6), (float)(2 * num - 22)));
			graphics.DrawString("7", font, Brushes.Green, new PointF((float)(num - num2 + 2), (float)(num + num3 - 19)));
			graphics.DrawString("8", font, Brushes.Green, new PointF((float)(num - num3 + 5), (float)(num + num2 - 14)));
			graphics.DrawString("9", font, Brushes.Green, new PointF(8f, (float)(num - 9)));
			graphics.DrawString("10", font, Brushes.Green, new PointF((float)(num - num3 + 4), (float)(num - num2 - 2)));
			graphics.DrawString("11", font, Brushes.Green, new PointF((float)(num - num2), (float)(num - num3 + 3)));
			graphics.DrawString("12", font, Brushes.Green, new PointF((float)(num - 10), 7f));
			Bitmap bitmap2 = new Bitmap(base.Width, base.Height);
			Graphics graphics2 = Graphics.FromImage(bitmap2);
			graphics2.DrawImage(bitmap, new Point(10, 10));
			bitmap.Dispose();
			return bitmap2;
		}

		/// <summary>
		/// 获取时钟的当前时间
		/// </summary>
		// Token: 0x17000632 RID: 1586
		// (get) Token: 0x06001E50 RID: 7760 RVA: 0x00091C28 File Offset: 0x0008FE28
		[Category("我的属性")]
		[Description("设置边框的宽度")]
		public DateTime 当前时间
		{
			get
			{
				return this._NowTime;
			}
		}

		/// <summary>
		/// 获取或设置时钟指针的颜色
		/// </summary>
		// Token: 0x17000633 RID: 1587
		// (get) Token: 0x06001E52 RID: 7762 RVA: 0x00091C4C File Offset: 0x0008FE4C
		// (set) Token: 0x06001E51 RID: 7761 RVA: 0x00091C40 File Offset: 0x0008FE40
		[Category("我的属性")]
		[Description("设置时钟的指针颜色")]
		[DefaultValue(typeof(Color), "Chocolate")]
		public Color 时钟指针颜色
		{
			get
			{
				return this._HourColor;
			}
			set
			{
				this._HourColor = value;
			}
		}

		/// <summary>
		/// 获取或设置时钟分钟指针颜色
		/// </summary>
		// Token: 0x17000634 RID: 1588
		// (get) Token: 0x06001E54 RID: 7764 RVA: 0x00091C70 File Offset: 0x0008FE70
		// (set) Token: 0x06001E53 RID: 7763 RVA: 0x00091C64 File Offset: 0x0008FE64
		[Category("我的属性")]
		[Description("设置分钟的指针颜色")]
		[DefaultValue(typeof(Color), "Coral")]
		public Color 分钟指针颜色
		{
			get
			{
				return this._MiniteColor;
			}
			set
			{
				this._MiniteColor = value;
			}
		}

		/// <summary>
		/// 获取或设置秒钟指针颜色
		/// </summary>
		// Token: 0x17000635 RID: 1589
		// (get) Token: 0x06001E56 RID: 7766 RVA: 0x00091C94 File Offset: 0x0008FE94
		// (set) Token: 0x06001E55 RID: 7765 RVA: 0x00091C88 File Offset: 0x0008FE88
		[Category("我的属性")]
		[Description("设置秒钟的指针颜色")]
		[DefaultValue(typeof(Color), "Green")]
		public Color 秒钟指针颜色
		{
			get
			{
				return this._SecondColor;
			}
			set
			{
				this._SecondColor = value;
			}
		}

		/// <summary>
		/// 获取或设置时钟的个性化文本
		/// </summary>
		// Token: 0x17000636 RID: 1590
		// (get) Token: 0x06001E58 RID: 7768 RVA: 0x00091CB8 File Offset: 0x0008FEB8
		// (set) Token: 0x06001E57 RID: 7767 RVA: 0x00091CAC File Offset: 0x0008FEAC
		[Category("我的属性")]
		[Description("设置时钟显示的字符串")]
		[DefaultValue(typeof(string), "Sweet")]
		public string 显示文本
		{
			get
			{
				return this._ShowText;
			}
			set
			{
				this._ShowText = value;
			}
		}

		/// <summary>
		/// 字体
		/// </summary>
		// Token: 0x17000637 RID: 1591
		// (get) Token: 0x06001E5A RID: 7770 RVA: 0x00091CDC File Offset: 0x0008FEDC
		// (set) Token: 0x06001E59 RID: 7769 RVA: 0x00091CD0 File Offset: 0x0008FED0
		[Category("我的属性")]
		[Description("设置时钟显示的字符串")]
		[DefaultValue(typeof(string), "Courier New")]
		public string 显示文本字体
		{
			get
			{
				return this._ShowTextFont;
			}
			set
			{
				this._ShowTextFont = value;
			}
		}

		/// <summary>
		/// 重绘控件显示
		/// </summary>
		/// <param name="e"></param>
		// Token: 0x06001E5B RID: 7771 RVA: 0x00091CF4 File Offset: 0x0008FEF4
		protected override void OnPaint(PaintEventArgs e)
		{
			bool flag = !Authorization.nzugaydgwadawdibbas();
			if (!flag)
			{
				base.OnPaint(e);
				int num = (base.Width - 21) / 2;
				int hour = this._NowTime.Hour;
				int minute = this._NowTime.Minute;
				float num2 = (float)this._NowTime.Second + (float)this._NowTime.Millisecond / 1000f;
				int num3 = hour * 30 + 270 + minute / 2;
				int num4 = minute * 6 + 270;
				float angle = num2 * 6f + 270f;
				Graphics graphics = e.Graphics;
				graphics.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
				Font font = new Font(this._ShowTextFont, 14f);
				Size size = graphics.MeasureString(this._ShowText, font).ToSize();
				graphics.DrawString(this._ShowText, font, Brushes.Green, new PointF((float)(num - size.Width / 2 + 10), (float)(num / 2 + 12)));
				graphics.SmoothingMode = SmoothingMode.AntiAlias;
				SizeF sizeF = graphics.MeasureString(this._NowTime.DayOfWeek.ToString(), new Font(this._ShowTextFont, 10f));
				graphics.DrawString(this._NowTime.DayOfWeek.ToString(), new Font(this._ShowTextFont, 10f), Brushes.Chocolate, new PointF((float)(num - sizeF.ToSize().Width / 2 + 10), (float)(num * 3 / 2 - 2)));
				graphics.TranslateTransform((float)(base.Width / 2), (float)(base.Width / 2));
				graphics.RotateTransform((float)num3, MatrixOrder.Prepend);
				graphics.DrawLine(new Pen(this._HourColor, 2f), new Point(4, 0), new Point(9, 0));
				graphics.DrawClosedCurve(new Pen(this._HourColor, 1f), new Point[]
				{
					new Point(12, 2),
					new Point(10, 0),
					new Point(12, -2),
					new Point(num / 2, -2),
					new Point(num / 2 + 6, 0),
					new Point(num / 2, 2)
				});
				graphics.RotateTransform((float)(-(float)num3));
				graphics.RotateTransform((float)num4, MatrixOrder.Prepend);
				graphics.DrawLine(new Pen(this._MiniteColor, 2f), new Point(4, 0), new Point(9, 0));
				graphics.DrawClosedCurve(new Pen(this._MiniteColor, 1f), new Point[]
				{
					new Point(14, 2),
					new Point(10, 0),
					new Point(14, -2),
					new Point(num - 17, -2),
					new Point(num - 10, 0),
					new Point(num - 17, 2)
				});
				graphics.RotateTransform((float)(-(float)num4));
				graphics.RotateTransform(angle, MatrixOrder.Prepend);
				graphics.DrawLine(new Pen(this._SecondColor, 1f), new Point(-13, 0), new Point(num - 6, 0));
				graphics.ResetTransform();
				string text = string.Concat(new string[]
				{
					this._NowTime.Year.ToString(),
					"-",
					this._NowTime.Month.ToString(),
					"-",
					this._NowTime.Day.ToString()
				});
				Size size2 = graphics.MeasureString(text, new Font(this._ShowTextFont, 12f)).ToSize();
				graphics.DrawString(text, new Font(this._ShowTextFont, 12f), Brushes.Green, new PointF((float)(num - size2.Width / 2 + 10), (float)(num * 2 + 15)));
			}
		}

		// Token: 0x06001E5C RID: 7772 RVA: 0x00092123 File Offset: 0x00090323
		private void ClockMy_SizeChanged(object sender, EventArgs e)
		{
			this.BackgroundImage = this._BackGround();
		}

		/// <summary> 
		/// 清理所有正在使用的资源。
		/// </summary>
		/// <param name="disposing">如果应释放托管资源，为 true；否则为 false。</param>
		// Token: 0x06001E5D RID: 7773 RVA: 0x00092134 File Offset: 0x00090334
		protected override void Dispose(bool disposing)
		{
			bool flag = disposing && this.components != null;
			if (flag)
			{
				this.components.Dispose();
			}
			base.Dispose(disposing);
		}

		/// <summary> 
		/// 设计器支持所需的方法 - 不要
		/// 使用代码编辑器修改此方法的内容。
		/// </summary>
		// Token: 0x06001E5E RID: 7774 RVA: 0x0009216C File Offset: 0x0009036C
		private void InitializeComponent()
		{
			base.SuspendLayout();
			base.AutoScaleDimensions = new SizeF(6f, 12f);
			base.AutoScaleMode = AutoScaleMode.Font;
			this.BackColor = Color.Transparent;
			this.Font = new Font("Courier New", 9f, FontStyle.Regular, GraphicsUnit.Point, 134);
			base.Name = "ClockMy";
			base.Size = new Size(130, 150);
			base.Load += this.ClockMy_Load;
			base.SizeChanged += this.ClockMy_SizeChanged;
			base.ResumeLayout(false);
		}

		// Token: 0x040006AB RID: 1707
		private Timer _Time1s = new Timer();

		// Token: 0x040006AC RID: 1708
		private DateTime _NowTime = DateTime.Now;

		// Token: 0x040006AD RID: 1709
		private Color _HourColor = Color.Chocolate;

		// Token: 0x040006AE RID: 1710
		private Color _MiniteColor = Color.Coral;

		// Token: 0x040006AF RID: 1711
		private Color _SecondColor = Color.Green;

		// Token: 0x040006B0 RID: 1712
		private string _ShowText = "Sweet";

		// Token: 0x040006B1 RID: 1713
		private string _ShowTextFont = "Courier New";

		/// <summary> 
		/// 必需的设计器变量。
		/// </summary>
		// Token: 0x040006B2 RID: 1714
		private IContainer components = null;
	}
}
